<!doctype html>
<html>
	<head>
		<title>羽乐汇</title>
		<meta name="keywords" content="羽毛球，球会，球场，教练">
		<meta name="charset" content="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/CSS/HomePage/bootstrap.min.css">
		<!-- <link rel="stylesheet" type="text/css" href="__PUBLIC__/CSS/HomePage/wap_index.css"> -->
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/CSS/HomePage/index.css">
		
		<script type="text/javascript" src="__PUBLIC__/JS/HomePage/jquery.min.js"></script>
		
		<script type="text/javascript" src="__PUBLIC__/JS/HomePage/bootstrap.min.js"></script>
		<script type="text/javascript" src="__PUBLIC__/JS/HomePage/md5.js"></script>
		<!--<script type="text/javascript" src="__PUBLIC__/JS/HomePage/index.js"></script>-->
    </head>
	<body>
	<!-- ---------------------------------------------------------------pc_index--------------------------------------------------------- -->
		<div class="pc_coach container-fluid">
			<!-- <div class="top visible-lg visible-md"> -->
		<div class="top visible-lg visible-md">
			<div class="ttop">
				<span>欢迎来到羽乐汇</span>
				<div>
					<span class="wellcome"></span>
					<span class="login">
						<button class="login_btn">登陆</button>
						<!-- <button class="notlogin_btn">注销</button> -->
						<a href="<{:U('Index/registration')}>">注册</a>
						
					</span>
					<!-- <button class="sign_btn">注册</button> -->
					<a class="login_after" href="<{:U('User/index')}>">个人主页</a>
					<a href="__PUBLIC__/HTML/vip_center.html">vip中心</a>
				</div>
			</div>
			<div>
				<img src="__PUBLIC__/PICTURE/HomePage/logo.jpg">
			</div>
			<div class="main_nav">
				<ul>
					<li><a href="<{:U('Index/index')}>">首页</a></li>
					<li><a href="<{:U('Gymnasium/index')}>">球场</a></li>
					<li><a href="<{:U('Club/index')}>">球会</a></li>
					<li>培训</li>
					<li><a href="<{:U('Activity/activity')}>">活动</a></li>
					<li><a href="<{:U('Coach/index')}>">教练</a></li>
					<li>竞赛</li>
					<li><a href="<{:U('Announce/index')}>">公告</a></li>
				</ul>
			</div>
		</div>
			<header class="row visible-xs visible-sm header_nav">
				<div class="top_search">
					<a href="<{:U('Gymnasium/index')}>" class="href"><img src="__PUBLIC__/PICTURE/HomePage/pre.png"/></a>
					<span>球场内订场情况</span>
				</div>
			</header>
			<div class="coach_content">
<!-- 					<div class="introduce_court">
					<div class="head"><span>返回上一页</span></div>
					<div class="court_about">
						<div class="img_div"><img src="" alt="头像"></div>
						<div class="content">
							<ul>
								<li><span>馆长：</span>某某某</li>
								<li>地址：<span>某某某某某某</span></li>
								<li>
									<div class="my_con visible-lg visible-md">
										<span>球馆介绍：</span><br/>
										<div>羽乐是一款便于羽毛球兴趣协会（球会）组织工作的工具软件为切入，聚合球会会员社交，球场O2O等多项功能的app软件。提供会员创建球会，组织活动，活动报名，活动积分，资料共享，会员聊天，球场订场，教练培训等多项功能，是羽毛球爱好者、球场经营者，羽球教练深度使用的应用软件</div>
									</div>
								</li>
							</ul>
						</div>
						<div class="visible-sm visible-xs my_con_wap">
							<span>球馆介绍：</span><br/>
							<div>羽乐是一款便于羽毛球兴趣协会（球会）组织工作的工具软件为切入，聚合球会会员社交，球场O2O等多项功能的app软件。提供会员创建球会，组织活动，活动报名，活动积分，资料共享，会员聊天，球场订场，教练培训等多项功能，是羽毛球爱好者、球场经营者，羽球教练深度使用的应用软件</div>
						</div>
					</div>
				</div> -->
				<div class="court_nav">
					<ul class="row list-unstyled nav1 container">
						<li class="col-lg-1 col-md-1">
							<div class="form-group">
								<select class="form-control" id="day">
	      						</select>
							</div>
						</li>
<!-- 						<li class="col-lg-1 col-md-1">
							<div class="form-group">
								<select class="form-control" id="clock">
	         						<option value="">8：00-9：00</option>
	         						<option value="">8：00-9：00</option>
	         						<option value="">8：00-9：00</option>
	         						<option value="">8：00-9：00</option>
	      						</select>
							</div>
						</li> -->
					</ul>
<!-- 					<ul class="row list-unstyled nav2">
					</ul> -->
				</div>
				<div class="coach_messege">
					<{:W('Gymnasium/courtLoad')}>
				</div>
			</div>
			<div class="content_foot">
				<ul>
					<li><button class="pageup" type="button" disabled="disabled">上一页</button></li>
					<li><button class="pagedown" type="button" disabled="disabled">下一页</button></li>
				</ul>
			</div>
		</div>
		<div class="foot row">
				
				<div>
					<p>联系我们</p>
					<p>关于我们</p>
					<p>加入我们</p>
				</div>
				<div>
					<p>电话：400-800-8888 周一至周六9：00-18：00</p>
					<p>[羽乐汇]<a href="http://oto.my3w.com">http://oto.my3w.com</a></p>
				</div>
		</div>
	</body>
	<script type="text/javascript">
	var test = [];
	var timestamp;//时间戳
	var gymnasium_id;//球馆ID
	var openHours = [];//开场时间数组
	var gymnasium_close_result;//球馆开闭
	var court_count;//球场数
	var courtJson;
	var page_num=1;//当前页数
	var gymnasium_open_time;
	var totalPage;
	test=<{$resultList}>;
	gymnasium_id=test.resultGymnasium.gymnasium_id;
	gymnasium_open_time=test.resultGymnasium.gymnasium_open_time;
	<!------------------------- 时间转换函数  ------------------------- -->
	//console.log($.myTime.DateToUnix('2014-5-15 20:20:20'));
	//console.log($.myTime.UnixToDate(1325347200));
	(function($) {
    $.extend({
        myTime: {
            /**
             * 当前时间戳
             * @return <int>        unix时间戳(秒)  
             */
            CurTime: function(){
                return Date.parse(new Date())/1000;
            },
            /**              
             * 日期 转换为 Unix时间戳
             * @param <string> 2014-01-01 20:20:20  日期格式              
             * @return <int>        unix时间戳(秒)              
             */
            DateToUnix: function(string) {
                var f = string.split(' ', 2);
                var d = (f[0] ? f[0] : '').split('-', 3);
                var t = (f[1] ? f[1] : '').split(':', 3);
                return (new Date(
                        parseInt(d[0], 10) || null,
                        (parseInt(d[1], 10) || 1) - 1,
                        parseInt(d[2], 10) || null,
                        parseInt(t[0], 10) || null,
                        parseInt(t[1], 10) || null,
                        parseInt(t[2], 10) || null
                        )).getTime() / 1000;
            },
            /**              
             * 时间戳转换日期              
             * @param <int> unixTime    待时间戳(秒)              
             * @param <bool> isFull    返回完整时间(Y-m-d 或者 Y-m-d H:i:s)              
             * @param <int>  timeZone   时区              
             */
            UnixToDate: function(unixTime, isFull, timeZone) {
                if (typeof (timeZone) == 'number')
                {
                    unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
                }
                var time = new Date(unixTime * 1000);
                var ymdhis = "";
                ymdhis += time.getUTCFullYear() + "-";
                ymdhis += (time.getUTCMonth()+1) + "-";
                ymdhis += time.getUTCDate();
                if (isFull === true)
                {
                    ymdhis += " " + time.getUTCHours() + ":";
                    ymdhis += time.getUTCMinutes() + ":";
                    ymdhis += time.getUTCSeconds();
                }
                return ymdhis;
            }
        }
    });
})(jQuery);
<!------------------------- 获取时间戳  ------------------------- -->
	/*
	timestamp=new Date().getTime();
	timestamp=timestamp.toString();
    timestamp=timestamp.substring(0,timestamp.length-3);
	var time =$.myTime.UnixToDate(timestamp);
	var datel=$.myTime.DateToUnix('2015-11-22');
	alert(datel);
	*/
<!------------------------- 获取未来10天的日期  ------------------------- -->
	var getDays = function(str,day_count,format){
	if(typeof str === "number"){
		format = day_count;
		day_count = str;
		str = new Date();
	}
	var date = new Date(str);
	var dates = [];
	for(var i=0;i<=day_count;i++){
		var d = null;
		" "
		if(format){
			var fmt = format;
			fmt = fmt.replace(/y{4}/,date.getFullYear());
			fmt = fmt.replace(/M{2}/,(date.getMonth()+1));
			fmt = fmt.replace(/d{2}/,date.getDate());
			d = fmt;
		}else{
			d = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
		}
		dates.push(d);
		date.setDate(date.getDate()+1);
	}
	return dates;
};

//document.write(getDays(10,"yyyy-MM-dd"));
var datelist=getDays(10,"yyyy-MM-dd");
<!------------------------- 添加至列表  ------------------------- -->
$("#day").append("<option value='Value'>选择日期</option>");
for(var i=0;i<=9;i++){
	$("#day").append("<option value='Value'>"+datelist[i]+"</option>");
}
<!------------------------- 监听函数,请求后台加载列表  ------------------------- -->
$(function(){
	var texts;
	$('#day').change(function(){
		texts=$(this).children('option:selected').text();
		timestamp=($.myTime.DateToUnix(texts))*1000;
		page_num=1;
		for (var i = 0; i <= 4; i++) {
			var courtname="#courtname"+i;
			var timelist="#timelist"+i;
			$(courtname).html("");
			$(timelist).empty();
		}
		$.post('__URL__/courtLoad',{'timestamp':timestamp, 'gymnasium_id':gymnasium_id,'page_num':page_num},function(fresultList){
				gymnasium_close_result=fresultList.gymnasium_close_result;
				page_num=fresultList.resultList.page_num;
				court_count=fresultList.resultList.resultCount;
				courtJson=fresultList.resultList.result;
    	},'json');
			setTimeout("setpage()",1000);
	});
});
	function setpage(){
			totalPage=Math.ceil(court_count/5);
			if(page_num>1){
				$(".pageup").attr('disabled',false);
			}
			else{
				$(".pageup").attr('disabled',true);
			}
			if(totalPage>page_num){
				$(".pagedown").attr('disabled',false);
			}
			else{
				$(".pagedown").attr('disabled',true);
			}
			if(page_num<totalPage){
				for (var i = 0; i <= 4; i++) {
					var courtname="#courtname"+i;
					var timelist="#timelist"+i;
					var booklist=courtJson[i].book_info_list;
					$(courtname).html("球场名（编号）："+courtJson[i].court_name);
					$(timelist).empty();
					$(timelist).append("<option value=''>可订时间段</option>");
					for(var k=0;k<=booklist.length-1;k++){
						if(booklist[k]===0){
							var begin=new Number(gymnasium_open_time)+new Number(k);
							var next=new Number(gymnasium_open_time)+new Number(k)+1;
						$(timelist).append("<option value=''>"+begin+"-"+next+"</option>");
						}
					}
				}
			}
			else{
				for (var i = 0; i <= court_count-(page_num-1)*5-1; i++) {
					var courtname="#courtname"+i;
					var timelist="#timelist"+i;
					var booklist=courtJson[i].book_info_list;
					alert(booklist.length);
					$(courtname).html("球场名（编号）："+courtJson[i].court_name);
					$(timelist).empty();
					$(timelist).append("<option value=''>可订时间段</option>");
					for(var k=0;k<=booklist.length-1;k++){
						if(booklist[k]==0){
						var begin=new Number(gymnasium_open_time)+new Number(k);
						var next=new Number(gymnasium_open_time)+new Number(k)+1;
						$(timelist).append("<option value=''>"+begin+"-"+next+"</option>");
						}
					}
				}
				for(var i = court_count-(page_num-1)*5; i <= 4; i++){
					var courtname="#courtname"+i;
					var timelist="#timelist"+i;
					$(courtname).html("");
					$(timelist).empty();
				}
			}
		}
		//上一页
		$('.pageup').bind('click',function(){
			page_num--;
			$.post('__URL__/courtLoad',{'timestamp':timestamp, 'gymnasium_id':gymnasium_id,'page_num':page_num},function(fresultList){
				gymnasium_close_result=fresultList.gymnasium_close_result;
				page_num=fresultList.resultList.page_num;
				court_count=fresultList.resultList.resultCount;
				courtJson=fresultList.resultList.result;
    	},'json');
			setTimeout("setpage()",1000);
		});
		//下一页
		$('.pagedown').bind('click',function(){
			$.post('__URL__/courtLoad',{'timestamp':timestamp, 'gymnasium_id':gymnasium_id,'page_num':page_num},function(fresultList){
				gymnasium_close_result=fresultList.gymnasium_close_result;
				page_num=fresultList.resultList.page_num;
				court_count=fresultList.resultList.resultCount;
				courtJson=fresultList.resultList.result;
    	},'json');
			setTimeout("setpage()",1000);
		});

	</script>
</html>
